<html>
<head><meta charset="utf-8"><title>generate a function directly in LLVM · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generate.20a.20function.20directly.20in.20LLVM.html">generate a function directly in LLVM</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211679226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generate%20a%20function%20directly%20in%20LLVM/near/211679226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sfzhu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generate.20a.20function.20directly.20in.20LLVM.html#211679226">(Sep 29 2020 at 20:24)</a>:</h4>
<p>I am trying to generate a function (e.g., generating an A+B function) in LLVM code that doesn't have corresponding Rust code.  Is it possible to write some LLVM code directly without MIR and HIR?</p>



<a name="211679440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generate%20a%20function%20directly%20in%20LLVM/near/211679440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sfzhu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generate.20a.20function.20directly.20in.20LLVM.html#211679440">(Sep 29 2020 at 20:26)</a>:</h4>
<p>By the way I hope I would be able to call it in some other functions</p>



<a name="211693106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generate%20a%20function%20directly%20in%20LLVM/near/211693106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generate.20a.20function.20directly.20in.20LLVM.html#211693106">(Sep 29 2020 at 22:28)</a>:</h4>
<p>do you need that inline? if not, you can compile it yourself and use FFI <code>extern "C"</code></p>



<a name="211711518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/generate%20a%20function%20directly%20in%20LLVM/near/211711518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sfzhu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/generate.20a.20function.20directly.20in.20LLVM.html#211711518">(Sep 30 2020 at 03:29)</a>:</h4>
<p>Sorry I didn't make it clear. I'd like to generate the function during codegen, and the function is depend on an existing function in the rust code. E.g., for a function named <code>hello</code> in the rust code, I'd like to generate a wrapper for it, which simply calls the <code>hello</code> function, named as "hello_wrapper".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>